<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组方法</title>
    <script>
        {
            //sort对象比较
            let grade=[
                {name:"张三",grade:76},
                {name:"李四",grade:86},
                {name:"王五",grade:23},
            ]
            let r=grade.sort((a,b)=>{
                if(a.grade>b.grade){
                    return 1;
                }else{
                    return -1;
                }
            })
            console.log(r);
            console.table(grade);
        }
        {
            let arr=[1,2,3,6,9,8]
            let r= arr.copyWithin(0, 3, 5);
            console.log(r);
            console.log(arr);
        }
        {
            let arr=[1,2,3,6,9,8];
            let r=arr.includes((num)=> num>8);
            console.log(r);
            console.log(arr);
        }
        {
            let arr=[[1,4,7],[2,6,[9]],[13],3]
            let r=arr.flat(Infinity);
            console.log(r);
            console.log(arr);
        }
        {
            let arr=[5, 12, 8, 130, 44];
            let r=arr.find((num)=> num>8);//只找第一个
            console.log(r);
            console.log(arr);
        }
        {
            let arr=[[1,4,7],[2,6,[9]],[13],3];
            let r=arr.flatMap((val,index)=>val);
            console.log(r);
            console.log(arr);
        }
        

    </script>

</head>
<body>
    
</body>
</html>